home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / MACSHELL / MS1 / COMMANDS / BUILTIN.C < prev    next >
Text File  |  1992-12-02  |  17KB  |  712 lines

  1. /*
  2.  *    MacShell Source File
  3.  *
  4.  *    Copyright (c) 1989, 1990, 1991, 1992  Suick Bay Technologies.  All rights reserved.
  5.  *
  6.  *
  7.  *    RESTRICTIONS ON MacShell program and source code.
  8.  *
  9.  *    Ñ╩MacShell¬ is a product of Suick Bay Technologies and is provided for
  10.  *    restricted use by the owner of the CDROM "Disk to the future II".
  11.  *
  12.  *    Ñ╩No permission is granted for any commercial use without the written
  13.  *    consent of the Suick Bay Technologies.
  14.  *
  15.  *    Ñ╩No permission is granted for any redistribution of any kind use without
  16.  *    the written consent of the Suick Bay Technologies.
  17.  *
  18.  *    Ñ╩Permission is granted to use this for any personal noncommercial use.
  19.  *
  20.  *    Ñ╩You may not distribute source or executable code at all, nor may you 
  21.  *    distribute it with or within a commercial product without the written
  22.  *    consent of the Suick Bay Technologies.  Please send modifications to 
  23.  *    the author for inclusion in updates to the program.  Thanks.
  24.  *
  25.  *
  26.  *    MacShell¬ IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  27.  *    WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  28.  *    PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
  29.  *
  30.  *    SUICK BAY TECHNOLOGIES SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  31.  *    INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY MACSHELL
  32.  *    OR ANY PART THEREOF. 
  33.  *
  34.  *    In no event will Suick Bay Technologies be liable for any lost revenue
  35.  *    or profits or other special, indirect and consequential damages, even if
  36.  *    Suick Bay Technologies has been advised of the possibility of such damages.
  37.  *
  38.  *    Suick Bay Technologies can be reached at:
  39.  *    
  40.  *    8768 Cottonwood lane
  41.  *    Maple Grove, MN 55369
  42.  *    Voice: (612) 425-7025
  43.  *    AppleLink: D5233
  44.  *    
  45.  *
  46.  *    No parts of this software may be reproduced or stored in a
  47.  *    retrieval system or transmitted in any form, or any means,
  48.  *    electronic, mechanical, photocopying, recording or otherwise,
  49.  *    without the prior written permission of Suick Bay Technologies.
  50.  *    
  51.  *    Spread the word and not the disk.
  52.  *    
  53.  *    SPK 020790    :    Moved alias/unalias commands to new file Alias.c
  54.  *                    Updated ResStrs to use types
  55.  *                    Added arguments to alias'd commands
  56.  *    SPK 012290    :    Initial
  57.  */
  58.  
  59. #include    "SystemPub.h"
  60. #include    "Proc.h"
  61. #include    "Path.h"
  62. #include    "ShellPub.h"
  63.  
  64. extern    int16    appResFile;
  65. #define    USERMENUBASE  200
  66.  
  67. /*******************************************************************/
  68.  
  69. void    AddShellResStr( char *ref, char *string, int32 type )
  70. {
  71. char    buf[ 256 ], **cp;
  72. int16    id;
  73.  
  74.     strcpy( buf, ref );
  75.     CtoPstr( buf );
  76.     CtoPstr( string );
  77.  
  78.     cp = (char **) NewString( string );
  79.     UseResFile( appResFile );
  80.     id = Unique1ID( type );
  81.     
  82.     AddResource( cp, type, id, buf );    
  83.     PtoCstr( string );
  84. }
  85.  
  86. void    AddShellString( char *ref, char *string )
  87. {
  88.     AddShellResStr( ref, string, STRRES );
  89. }
  90.  
  91. /*******************************************************************/
  92.  
  93. char    **GetShellResStr( char *ref, int32 type )
  94. {
  95. char    buf[ 256 ], **ch;
  96.  
  97.     strcpy( buf, ref );
  98.     CtoPstr( buf );
  99.     UseResFile( appResFile );
  100.     
  101.     ch = (char **) GetNamedResource( type, buf );
  102.     return( ch );    /* handle to string */
  103. }
  104.  
  105. char    **GetShellString( char *ref )
  106. {
  107.     return( GetShellResStr( ref, STRRES ) );
  108. }
  109.  
  110. /*******************************************************************/
  111.  
  112. void    RemShellResStr( char *ref, int32 type  )
  113. {
  114. char    buf[ 256 ], **cp;
  115.  
  116.     strcpy( buf, ref );
  117.     CtoPstr( buf );
  118.     
  119.     cp = (char **) GetNamedResource( type, buf );
  120.     
  121.     if( cp )
  122.         {
  123.         RmveResource( cp );
  124.         DisposHandle( cp );
  125.         }
  126. }
  127.  
  128. void    RemShellString( char *ref )
  129. {
  130.     RemShellResStr( ref, STRRES );
  131. }
  132.  
  133. /*******************************************************************/
  134.  
  135. void    RemShellResStrs( int32 type )
  136. {
  137. int16    i;
  138. Handle    h;
  139.  
  140.     UseResFile( appResFile );
  141.     i = Count1Resources( type );
  142.     SetResLoad( FALSE );
  143.     
  144.     while( i )
  145.         {
  146.         h = GetIndResource( type, i );
  147.         RmveResource( h );
  148.         DisposHandle( h );
  149.         i--;
  150.         }
  151.         
  152.     SetResLoad( TRUE );
  153. }
  154.  
  155. void    RemShellStrings()
  156. {
  157.     RemShellResStrs( STRRES );
  158.     RemShellResStrs( ALSRES );
  159. }
  160.  
  161. /*******************************************************************/
  162.  
  163. DoUserMenu( int16 item, MHandle Mh )
  164. {
  165. char    *cp, *np, menuName[ 256 ], itemName[ 256 ], **ch;
  166. int16    i;
  167.  
  168.     if( currShell == NULL )        /* can't operate without a shell */
  169.         return;
  170.     
  171.     GetItem( (**Mh).mhMenu, item, itemName );
  172. /*
  173.  *    Get the command string
  174.  *    Execute the command sring
  175.  */
  176.     cp = (char *) (**(**Mh).mhMenu).menuData;
  177.     i = *cp + 1;
  178.     np = menuName;
  179.         
  180.     while( i-- )
  181.         *np++ = *cp++;
  182.         
  183.     PtoCstr( menuName );
  184.     PtoCstr( itemName );
  185.     strcat( menuName, itemName );
  186.  
  187.     ch = GetShellString( menuName );
  188.     
  189.     if( ch )
  190.         {
  191.         CopyStr( *ch, itemName );
  192.         PtoCstr( itemName );
  193.         strcat( itemName, "\n" );
  194.         CommandString( itemName, currShell );
  195.         }
  196. }
  197.  
  198. /*******************************************************************/
  199.  
  200. StripMetaChars( char *str )
  201. {
  202. char    *s, *l;
  203.  
  204.     s = str;
  205.     l = str;
  206.     while( *l )
  207.         {
  208.         switch( *l )
  209.             {
  210.             case    '^'    :    /* icon number */
  211.             case    '!'    :    /* mark character */
  212.             case    '<'    :    /* B, I, U, O, S style */
  213.             case    '/'    :    /* command key */
  214.                 *l++;                
  215.             case    '('    :    /* disable item */
  216.             case    ';'    :    /* separate item */
  217.                 *l++;
  218.                 break;
  219.                 
  220.             default :
  221.                 *s++ = *l++;
  222.             }
  223.         }
  224.         
  225.     *s = *l;    /* add the NULL */
  226. }
  227.  
  228. /*******************************************************************/
  229.  
  230. int16        menuID = USERMENUBASE;
  231.  
  232. Boolean        BuiltInCMD( WHandle ShellWh, int16 ProcID, int16 ShellProcID, 
  233.                 char *command )
  234. {
  235. WHandle            tempWh = 0L;
  236. ShellWindRec    **MyShell;
  237. char            argument[ 256 ];
  238. int16            i, argc;
  239.  
  240.     MyShell = (ShellWindRec **) (**ShellWh).thing;
  241.     argc = (**MyShell).Proc[ ProcID ].argc;
  242.     tempWh++;
  243.  
  244.     if( strcmp( "new", command ) == 0 )
  245.         ShellWindInit( "\pShell" );
  246.     else if( strcmp( "addmenu", command ) == 0 && (argc > 1))
  247.         {
  248.         MHandle     Mh;
  249.         MenuHandle    theMenu;
  250.         char    item[ 256 ];
  251.         char    name[ 256 ];
  252.         int16        found, menuItems;
  253.         
  254.         GetArgv( ShellWh, ProcID, 1, argument );    /* menu name */
  255.         if( argc > 2 )
  256.             GetArgv( ShellWh, ProcID, 2, item );        /* item name */
  257.         /* Does the menu exist ? */    
  258.         Mh = GetMhByName( argument );
  259.         
  260.         if( Mh == NULL )    /* no, make menu */
  261.             {
  262.             CtoPstr( argument );
  263.             theMenu = NewMenu( menuID++, argument );
  264.             
  265.             CtoPstr( item );
  266.             InsMenuItem( theMenu, item, 31 );
  267.         
  268.             SBTMenu( theMenu, &DoUserMenu, NULL );
  269.             /* Save the command string */
  270.             if( argc > 3 )
  271.                 {
  272.                 PtoCstr( argument );
  273.                 PtoCstr( item );
  274.                 
  275.                  StripMetaChars( item );
  276.                 strcat( argument, item );
  277.                 GetArgv( ShellWh, ProcID, 3, item );    /* command string */
  278.                 AddShellString( argument, item );
  279.                 }
  280.             }
  281.         else if( argc > 2 )    /* yes, now the item */
  282.             {
  283.             if( (**Mh).mhID < USERMENUBASE )
  284.                 return( TRUE );
  285.  
  286.             /* Does the item exist ? */
  287.              found = FALSE;
  288.              menuItems = CountMItems( (**Mh).mhMenu );
  289.              StripMetaChars( item );
  290.              
  291.              for( i = 1; i <= menuItems; i++ )
  292.                  {
  293.                 GetItem( (**Mh).mhMenu, i, name );
  294.                 PtoCstr( name );
  295.                 if( strcmp( name, item ) == 0 )
  296.                     {
  297.                     /* found it */
  298.                     found = TRUE;
  299.                     break;
  300.                     }
  301.                  }
  302.  
  303.             if( found )
  304.                 {
  305.                 /* redo the item because it could have different meta-chars */
  306.                 
  307.                 
  308.                 /* redo the command */
  309.                 if( argc > 3 )
  310.                     {
  311.                     /* Remove the old command string */
  312.                     strcat( argument, item );
  313.                     RemShellString( argument );
  314.                     
  315.                     /* Save the new command string */
  316.                     GetArgv( ShellWh, ProcID, 3, item );    /* command string */
  317.                     AddShellString( argument, item );
  318.                     }
  319.                 }
  320.             else
  321.                 {
  322.                 GetArgv( ShellWh, ProcID, 2, item );        /* item name */
  323.                 CtoPstr( item );
  324.                 InsMenuItem( (**Mh).mhMenu, item, 0 );
  325.                 /* Save the command string */
  326.                 if( argc > 3 )
  327.                     {
  328.                     PtoCstr( item );
  329.                      StripMetaChars( item );
  330.                     strcat( argument, item );
  331.                     GetArgv( ShellWh, ProcID, 3, item );    /* command string */
  332.                     AddShellString( argument, item );
  333.                     }
  334.                 }
  335.             }
  336.         }
  337.     else if( (strcmp( "addsubmenu", command ) == 0) && (argc > 3) )
  338.         {
  339.         char        str1[ 64 ], str2[ 64 ], name[ 64 ];
  340.         MHandle     theMh, inMh;
  341.         MenuHandle    theMenu;
  342.         int16            found, menuItems, inMenuItem;
  343.         
  344.         GetArgv( ShellWh, ProcID, 1, str1 );        /* menu name */
  345.         GetArgv( ShellWh, ProcID, 2, str2 );        /* item name */
  346.         /* Does the menu exist ? */    
  347.         inMh = GetMhByName( str1 );
  348.  
  349.         if( inMh )
  350.             {
  351.             if( (**inMh).mhID < USERMENUBASE )
  352.                 return( TRUE );
  353.  
  354.             /* Does the item exist ? */
  355.             found = FALSE;
  356.              menuItems = CountMItems( (**inMh).mhMenu );
  357.              StripMetaChars( str2 );
  358.              
  359.              for( i = 1; i <= menuItems; i++ )
  360.                  {
  361.                 GetItem( (**inMh).mhMenu, i, name );
  362.                 PtoCstr( name );
  363.                 if( strcmp( str2, name ) == 0 )
  364.                     {
  365.                     /* found it */
  366.                     found = TRUE;
  367.                     break;
  368.                     }
  369.                  }
  370.                  
  371.              if( found )        /* found the menu */
  372.                  {
  373.                  inMenuItem = i;
  374.                  GetArgv( ShellWh, ProcID, 3, str1 );    /* sub menu name */
  375.  
  376.                 theMh = GetMhByName( str1 );
  377.                  
  378.                 if( theMh && (**theMh).mhID < USERMENUBASE )
  379.                     return( TRUE );
  380.                     
  381.                  if( theMh && argc > 4 )        /* sub menu exsists */
  382.                      {
  383.                     found = FALSE;
  384.                      menuItems = CountMItems( (**theMh).mhMenu );
  385.                      GetArgv( ShellWh, ProcID, 4, str2 );    /* sub menu name */
  386.                      StripMetaChars( str2 );
  387.                      
  388.                      for( i = 1; i <= menuItems; i++ )
  389.                          {
  390.                         GetItem( (**theMh).mhMenu, i, name );
  391.                         PtoCstr( name );
  392.                         if( strcmp( str2, name ) == 0 )
  393.                             {
  394.                             /* found it */
  395.                             found = TRUE;
  396.                             break;
  397.                             }
  398.                          }
  399.                      
  400.                      if( found )            /* sub menu item  exists */
  401.                          {
  402.                          if( argc > 5)    /* command exists */
  403.                              {
  404.                             /* Remove the old command string */
  405.                             strcat( str1, str2 );
  406.                             RemShellString( str1 );
  407.                             /* Save the new command string */
  408.                             GetArgv( ShellWh, ProcID, 5, str2 );    /* command string */
  409.                             AddShellString( str1, str2 );
  410.                             }
  411.                         }
  412.                      else            /* new item */
  413.                          {
  414.                         GetArgv( ShellWh, ProcID, 4, str2 );        /* item name */
  415.                         CtoPstr( str2 );
  416.                         InsMenuItem( (**theMh).mhMenu, str2, 0 );
  417.                         /* Save the command string */
  418.                         if( argc > 5 )
  419.                             {
  420.                             PtoCstr( str2 );
  421.                              StripMetaChars( str2 );
  422.                             strcat( str1, str2 );
  423.                             GetArgv( ShellWh, ProcID, 5, str2 );    /* command string */
  424.                             AddShellString( str1, str2 );
  425.                             }
  426.                          }
  427.                      }
  428.                  else            /* make sub menu */
  429.                      {
  430.                     GetArgv( ShellWh, ProcID, 3, str1 );
  431.                     CtoPstr( str1 );
  432.                     theMenu = NewMenu( menuID++, str1 );
  433.                     
  434.                     GetArgv( ShellWh, ProcID, 4, str2 );
  435.                     CtoPstr( str2 );
  436.                     InsMenuItem( theMenu, str2, 31 );
  437.                 
  438.                     SBTHierMenu( theMenu, (**inMh).mhMenu, inMenuItem, &DoUserMenu, NULL);
  439.                     
  440.                     /*    Save the command string */
  441.                     if( argc > 5 )
  442.                         {
  443.                         PtoCstr( str1 );
  444.                         PtoCstr( str2 );
  445.                         
  446.                          StripMetaChars( str2 );
  447.                         strcat( str1, str2 );
  448.                         GetArgv( ShellWh, ProcID, 5, str2 );    /* command string */
  449.                         AddShellString( str1, str2 );
  450.                         }
  451.                      }
  452.                  }
  453.             }
  454.         }
  455.     else if( strcmp( "delmenu", command ) == 0 && (argc > 1))
  456.         {
  457.         MHandle     Mh;
  458.         char        item[ 64 ];
  459.         char        name[ 64 ];
  460.         int16        found, menuItems;
  461.         
  462.         GetArgv( ShellWh, ProcID, 1, argument );    /* menu name */
  463.         if( argc > 2 )
  464.             GetArgv( ShellWh, ProcID, 2, item );    /* item name */
  465. /*
  466.  *    Does the menu exist ?
  467.  */    
  468.         Mh = GetMhByName( argument );
  469.         
  470.         if( Mh != NULL )    /* delete menu */
  471.             {
  472.             if( (**Mh).mhID < USERMENUBASE )
  473.                 return( TRUE );
  474.             
  475.             if( argc > 2 )
  476.                 {
  477.                 found = TRUE;
  478.                 
  479.                 while( found && !UserAbort())    /* remove all occurences */
  480.                     {
  481.                     found = FALSE;
  482.                      menuItems = CountMItems( (**Mh).mhMenu );
  483.                      StripMetaChars( item );
  484.                      for( i = 1; i <= menuItems; i++ )
  485.                          {
  486.                         GetItem( (**Mh).mhMenu, i, name );
  487.                         PtoCstr( name );
  488.                         if( StrPatMatch( name, item ) )
  489.                             {
  490.                             /* found it */
  491.                             found = TRUE;
  492.                             break;
  493.                             }
  494.                          }
  495.                          
  496.                     GetArgv( ShellWh, ProcID, 2, item );    /* item name */
  497.                      if( found )
  498.                          {
  499.                          DelMenuItem( (**Mh).mhMenu, i );
  500.                         /*    Remove the command string */
  501.                         strcat( argument, item );
  502.                         RemShellString( argument );
  503.                          }
  504.                      }
  505.                 }
  506.             else    /* remove the menu */
  507.                 {
  508.                  char    str[ 256 ];
  509.                 /* Remove the command strings */
  510.                  menuItems = CountMItems( (**Mh).mhMenu );
  511.                 for( i = 1; i < menuItems; i++ )
  512.                      {
  513.                     GetItem( (**Mh).mhMenu, i, name );
  514.                     PtoCstr( name );
  515.                     
  516.                     strcpy( str, argument );
  517.                     strcat( argument, item );
  518.                     RemShellString( argument );
  519.                     }
  520.                     
  521.                 SBTRmveMenu( (**Mh).mhMenu, TRUE );
  522.                 DrawMenuBar();
  523.                 }
  524.             }
  525.         }
  526.     else if( strcmp( "open", command ) == 0 )
  527.         {
  528.         extern    Boolean    read;
  529.  
  530.         if( argc == 1 )
  531.             WindowMessage( ShellWh, OpenMsg );
  532.         else
  533.             {
  534.             read = FALSE;
  535.             for( i = 1; i < argc; i++ )
  536.                 {
  537.                 GetArgv( ShellWh, ProcID, i, argument );
  538.                 LoadFileIntoWind( ShellWh, ProcID, argument );
  539.                 }
  540.             }
  541.         }
  542.     else if( strcmp( "close", command ) == 0 )
  543.         {
  544.         for( i = 1; i < argc; i++ )
  545.             {
  546.             GetArgv( ShellWh, ProcID, i, argument );
  547.             while( tempWh && !UserAbort() )
  548.                 {
  549.                 /* don't scan 'From' here because of changing list */
  550.                 
  551.                 tempWh = GetWhByName( argument );
  552.                 
  553.                 if( tempWh != ShellWh )
  554.                     WindowMessage( tempWh, CloseMsg );
  555.                 }
  556.             }
  557.         }
  558.     else if( strcmp( "save", command ) == 0 )
  559.         {
  560. #ifndef    DEMO
  561.         for( i = 1; i < argc; i++ )
  562.             {
  563.             GetArgv( ShellWh, ProcID, i, argument );
  564.             while( tempWh && !UserAbort() )
  565.                 {
  566.                 tempWh = GetWhByNameFrom( argument, tempWh );
  567.                 WindowMessage( tempWh, SaveMsg );
  568.                 }
  569.             }
  570. #else
  571.         printf( "Demo version, save is not available\n" );
  572. #endif
  573.         }
  574.     else if( strcmp( "saveas", command ) == 0 )
  575.         {
  576. #ifndef    DEMO
  577.         for( i = 1; i < argc; i++ )
  578.             {
  579.             GetArgv( ShellWh, ProcID, i, argument );
  580.             while( tempWh && !UserAbort() )
  581.                 {
  582.                 tempWh = GetWhByNameFrom( argument, tempWh );
  583.                 WindowMessage( tempWh, SaveAsMsg );
  584.                 }
  585.             }
  586. #else
  587.         printf( "Demo version, saveas is not available\n" );
  588. #endif
  589.         }
  590.     else if( strcmp( "revert", command ) == 0 )
  591.         {
  592.         for( i = 1; i < argc; i++ )
  593.             {
  594.             GetArgv( ShellWh, ProcID, i, argument );
  595.             while( tempWh && !UserAbort() )
  596.                 {
  597.                 tempWh = GetWhByNameFrom( argument, tempWh );
  598.                 if( tempWh != ShellWh )
  599.                     WindowMessage( tempWh, RevertMsg );
  600.                 }
  601.             }
  602.         }
  603.     else if( strcmp( "pagesetup", command ) == 0 )
  604.         {
  605.         DoPageSetup();
  606.         }
  607.     else if( strcmp( "print", command ) == 0 )
  608.         {
  609.         if( argc == 1 )
  610.             {
  611.             tempWh = GetWHandler(FrontWindow());
  612.             if( tempWh )
  613.                 WindowMessage( tempWh, PrintMsg );
  614.             }
  615.         else
  616.             for( i = 1; i < argc; i++ )
  617.                 {
  618.                 GetArgv( ShellWh, ProcID, i, argument );
  619.                 while( tempWh && !UserAbort() )
  620.                     {
  621.                     tempWh = GetWhByNameFrom( argument, tempWh );
  622.                     WindowMessage( tempWh, PrintMsg );
  623.                     }
  624.             }
  625.         }
  626.     else if( strcmp( "quit", command ) == 0 )
  627.         SBTQuit();
  628.  
  629.     else if( strcmp( "undo", command ) == 0 )        {}
  630.     else if( strcmp( "select", command ) == 0 )        {}
  631.     else if( strcmp( "cut", command ) == 0 )        {}
  632.     else if( strcmp( "copy", command ) == 0 )        {}
  633.     else if( strcmp( "paste", command ) == 0 )        {}
  634.     
  635.     else if( strcmp( "clear", command ) == 0 )
  636.         {
  637.         if( argc == 1 )        /* clear the shell */
  638.             ClearShellOutput( ShellWh );
  639.         }
  640.     else if( strcmp( "shutdown", command ) == 0 )
  641.         ShutDwnPower();
  642.         
  643.     else if( strcmp( "restart", command ) == 0 )
  644.         ShutDwnStart();
  645.         
  646.     else if( strcmp( "sh", command ) == 0 )
  647.         ShellWindInit( "\pShell" );
  648.         
  649.     else if( strcmp( "about", command ) == 0 )
  650.         DoAbout();
  651.         
  652.     else if( strcmp( "clean", command ) == 0 )
  653.         CleanUpWindows();
  654.         
  655.     else if( strcmp( "sdb", command ) == 0 )
  656.         {
  657.         printf( "MyShell %lX\n", MyShell );
  658.         printf( "    file name .. %ps\n",(**MyShell).fileName );
  659.         printf( "    new ........ %d\n", (**MyShell).new );
  660.         printf( "    dirty ...... %d\n", (**MyShell).dirty );
  661.         printf( "    vRefNum .... %d\n", (**MyShell).vRefNum );
  662.         printf( "    wantsInput . %d\n", (**MyShell).wantsInput );
  663.         printf( "    readOnly ... %d\n", (**MyShell).readOnly );
  664.         
  665.         printf( "    numProcs ... %d\n", (**MyShell).numProcs );
  666.         printf( "    prompt ..... %d\n", (**MyShell).prompt );
  667.         printf( "    promptBase . %ld\n",(**MyShell).promptBase );
  668.         printf( "    pwdVRefNum . %d\n", (**MyShell).pwdVRefNum );
  669.         printf( "    pwdDirID ... %ld\n", (**MyShell).pwdDirID );
  670.         printf( "    parDirID ... %ld\n", (**MyShell).parDirID );
  671.         printf( "    shellID .... %d\n", (**MyShell).shellID );
  672.         
  673.             {
  674.             int16    vRefNum;
  675.             int32    dirID, parDirID;
  676.             
  677.             GetPWDInfo( &vRefNum, &dirID, &parDirID );
  678.             printf( "PWD From OS : vRef %d dirID %ld parDirID\n", vRefNum, dirID, parDirID );
  679.             }
  680.         }
  681.         
  682.     else if( (strcmp( "help", command ) == 0) || (strcmp( "?", command ) == 0) )
  683.         procPrintf( ShellWh, ShellProcID, "try man or usage.\n" );
  684.         
  685.     else    /* could it be an alias ? */
  686.         {
  687.         char    alias[ 256 ];
  688.         char    **ch  = GetShellResStr( command, ALSRES );
  689.         
  690.         if( ch )
  691.             {
  692.             CopyStr( *ch, alias );
  693.             PtoCstr( alias );
  694.             
  695.             /* add the arguments to the aliased command */
  696.             for( i = 1; i < argc; i++ )
  697.                 {
  698.                 GetArgv( ShellWh, ProcID, i, argument );
  699.                 strcat( alias, " " );
  700.                 strcat( alias, argument );
  701.                 }            
  702.             
  703.             strcat( alias, "\n" );
  704.             CommandString( alias, ShellWh );
  705.             }
  706.         else
  707.             return( FALSE );
  708.         }
  709.     
  710.     return( TRUE );    
  711. }
  712.